data

Source: https://files.axds.co/portals/sanctsound/plots/manifest.html by Brian Stone

Files, per NCEI products Readme.docx:

  • SanctSound_CI01_01_BB_1h.csv Channel Islands NMS, site 1, deployment 1, Broadband Sound Pressure Level, hourly
  • SanctSound_CI01_01_OL_1h.csv Channel Islands NMS, site 1, deployment 1, Octave Level, hourly
  • SanctSound_CI01_01_PSD_1h.csv Channel Islands NMS, site 1, deployment 1, Power Spectral Density, hourly
library(readr)
library(dplyr)
library(tidyr)
library(purrr)
library(here)
library(DT)
# install.packages("ggplot2movies")

csvs <- list(
  bb  = here("data/SanctSound_CI01_01_BB_1h.csv"),
  ol  = here("data/SanctSound_CI01_01_OL_1h.csv"),
  psd = here("data/SanctSound_CI01_01_PSD_1h.csv"))

d <- map(csvs, read_csv)

d_smry <- tibble(
  dataset = names(d),
  cols    = map(dataset, function(x) names(d[[x]])),
  cols13  = map_chr(cols, function(x) paste(x[1:min(length(x),13)], collapse = ",")),
  dim     = map_chr(dataset, function(x) paste(dim(d[[x]]), collapse = " x ")))

d_smry %>% 
  select(dataset, dim, cols13) %>% 
  datatable()

octave level

ol <- d[["ol"]] %>% 
  rename(hour = `yyyy-mm-ddTHH:MM:SSZ`) %>% 
  select(-X13) %>% 
  pivot_longer(-hour, names_to = "octave", values_to = "level") %>% 
  mutate(
    hour_int  = as.double(hour - min(hour), units = "hours") %>%
      as.integer(),
    level_int = as.integer(level))

ol %>% 
  head(1000) %>% 
  datatable()

movies example

data(movies, package = "ggplot2movies")
movies_long <- movies  %>%
  dplyr::select(year, Action, Animation, Comedy, Drama, Documentary, Romance, Short) %>%
  tidyr::gather(genre, value, -year) %>%
  group_by(year, genre) %>%
  summarise(n = sum(value)) %>% 
  ungroup()

movies_long %>% 
  head(1000) %>% 
  datatable()

streamgraph

movies example

library(streamgraph)

movies_long %>%
  streamgraph("genre", "n", "year") %>%
  sg_axis_x(20, "year", "%Y") %>%
  sg_fill_brewer("PuOr") %>%
  sg_legend(show=TRUE, label="Genres: ")

octave level

ol %>% 
  streamgraph(date = "hour", value = "level_int", key = "octave") %>%
  sg_axis_x(1, "month", "%Y-%m") %>%
  sg_fill_brewer("Spectral") %>%
  #sg_fill_brewer("PuOr") %>%
  sg_legend(show=TRUE, label="Octaves: ")

highcharter

movies example

library(highcharter)

movies_long %>% 
  hchart("streamgraph", hcaes(year, n, group = genre)) %>% 
  hc_yAxis(visible = FALSE)

octave level

ol %>% 
  hchart("streamgraph", hcaes(hour_int, level, group = octave))